Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
Error encountered during contract execution [stack underflow (0 <=> 2)]

I'm developing an ERC721 contract. Whenever i call my mint function, i get this error :

Error encountered during contract execution [stack underflow (0 <=> 2)]

My function contains nothing but a simple require and return statement.

Any Help would be very much appriciated

I then downgraded to Sol 0.6.6 But i keep getting the same issue. Even meta mask shows this message when im about to confirm the transaction :

enter image description here

This is my Mint function :

function Mint() notBroke external payable returns (uint256) {  

    require(msg.value >= 0.05 ether, 'You didnt pay enough Eth Buddy :/'); 

    return 1;
}

This is My notBroke Modifier :

   modifier notBroke() {
    require(address(this).balance > 0 ether,"You  Broke");
    _;
}

And this is how I am committing the transaction from the Front end (using meta mask) :

        const transactionParameters = {
              to: Contract.address, 
              from: props.account, // must match user's active address.
              value: parseInt(Web3.utils.toWei("0.05", 'ether')).toString(16), 
              data: web3.eth.abi.encodeFunctionCall(    
                {
                    "inputs": [],
                    "name": "Mint",
                    "outputs": [
                      {
                        "internalType": "uint256",
                        "name": "",
                        "type": "uint256"
                      }
                    ],
                    "stateMutability": "payable",
                    "type": "function"
                  },[]
            ),
              chainId: `0x${parseInt(props.network)}`, // Used to prevent transaction reuse across blockchains. Auto-filled by MetaMask.
            };


            await window.ethereum.request({
              method: 'eth_sendTransaction',
              params: [transactionParameters],
            }).then( (result) => {

                 resolve(result) 

            }).catch((error)=> resolve(error))

And this is whats shown on Etherscan :

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Here you have added modifier Which means your contract should have balance greater then 0, so at first time your contract will have 0 ether so it will revert transaction, please try to check balance of your contract and I think so you should check balance user who want to mint token

about 4 years ago · Juan Pablo Isaza Denunciar

0

The modifier throws an exception (effectively reverting the transaction) with message "You Broke" if the contract address (not the sender address) has 0 balance.


If you want to update the modifier to revert only if the sender address has 0 balance, you need to use msg.sender instead of address(this):

require(msg.sender.balance > 0 ether,"You  Broke");
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda